package com.yb.personelmanagement.service.jwt;

import com.yb.personelmanagement.domain.System.User;
import com.yb.personelmanagement.domain.System.UserRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * @Auther: lzx
 * @Date: 2019/8/8 09:47
 * @Description: 根据用户名查询用户是否存在
 */
@Service
@Slf4j
public class JwtUserDetailsService implements UserDetailsService {
    @Autowired
    UserRepository userRepository;

    public User loadUserByUsername(String userName) throws UsernameNotFoundException {
        User user= userRepository.findByUserName(userName);

      //  log.info("根据用户名查询jwtUser{}",(jwtUser==null?"{}": JSON.parseObject(jwtUser)));
        return user;
    }

    //

}
